home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / tools / gcc / gcc270_src.lha / gcc-2.7.0-amiga / config / rs6000 / eabi.asm < prev    next >
Encoding:
Assembly Source File  |  1995-05-16  |  4.6 KB  |  174 lines

  1. # File to either setup register 2 to point to the GOT, or to adjust the
  2. # pointers in the .got2 section to point to their new addresses.
  3.  
  4.     .file    "eabi.asm"
  5.     .section ".text"
  6.     .globl     __eabi
  7.  
  8.      .section ".got2","aw"
  9. .LCTOC1 = . # +32768
  10.  
  11. # Table of addresses
  12. .Ltable = .-.LCTOC1
  13.     .long    .LCTOC1                # address we are really at
  14.  
  15. .Lgot = .-.LCTOC1
  16.     .long    _GLOBAL_OFFSET_TABLE_        # normal GOT address
  17.  
  18. .Lgots = .-.LCTOC1
  19.     .long    _GOT_START_            # start of .got section
  20.  
  21. .Lgote = .-.LCTOC1
  22.     .long    _GOT_END_            # end of .got section
  23.  
  24. .Lgot2s = .-.LCTOC1
  25.     .long    _GOT2_START_            # -mrelocatable GOT pointers start
  26.  
  27. .Lgot2e = .-.LCTOC1
  28.     .long    _GOT2_END_            # -mrelocatable GOT pointers end
  29.  
  30.     .text
  31. .Lptr:
  32.     .long    .LCTOC1-.Laddr            # PC relative pointer to .got2
  33.     .long    0x4000                # traceback table
  34.  
  35. __eabi:    mflr    0
  36.     bl    .Laddr                # get current address
  37. .Laddr:
  38.     mflr    12                # real address of .Laddr
  39.     lwz    11,(.Lptr-.Laddr)(12)        # linker generated address of .LCTOC1
  40.     add    11,11,12            # correct to real pointer
  41.     lwz    12,.Ltable(11)            # get linker's idea of where .Laddr is
  42.     subf.    12,12,11            # calculate difference
  43.     mtlr    0                # restore link register
  44.     bc    4,2,.Lreloc            # skip if we need to relocate
  45.  
  46. # Only load up register 2 if there is a .got section
  47.  
  48.     lwz    3,.Lgots(11)            # start of .got section
  49.     lwz    4,.Lgote(11)            # end of .got section
  50.     cmpw    1,3,4                # .got section non-empty?
  51.     bc    12,6,.Ldone
  52.  
  53. # Normal program, load up register 2
  54.  
  55.     lwz    2,.Lgot(11)            # normal GOT address
  56.     b    __do_global_ctors        # do any C++ global constructors (which returns to caller)
  57.  
  58. # We need to relocate the .got2 pointers.  Don't load register 2
  59.  
  60. .Lreloc:
  61.     lwz    3,.Lgot2s(11)            # GOT pointers start
  62.     lwz    4,.Lgot2e(11)            # GOT pointers end
  63.     add    3,12,3                # adjust pointers
  64.     add    4,12,4
  65.  
  66.     cmpw    1,3,4                # any pointers to adjust
  67.     bc    12,6,.Ldone
  68.  
  69. .Lloop:
  70.     lwz    11,0(3)                # next pointer
  71.     add    11,11,12            # adjust
  72.     stw    11,0(3)
  73.     addi    3,3,4                # bump to next word
  74.     cmpw    1,3,4                # more pointers to adjust?
  75.     bc    4,6,.Lloop
  76.  
  77. # Done adjusting pointers, return
  78.  
  79. .Ldone:
  80.     b    __do_global_ctors        # do any C++ global constructors (which returns to caller)
  81.  
  82. # Routines for saving floating point registers, called by the compiler.
  83. # Called with r11 pointing to the stack header word of the caller of the
  84. # function, just beyond the end of the floating point save area.
  85.  
  86.     .globl    _savefpr_14_l
  87.     .globl    _savefpr_15_l
  88.     .globl    _savefpr_16_l
  89.     .globl    _savefpr_17_l
  90.     .globl    _savefpr_18_l
  91.     .globl    _savefpr_19_l
  92.     .globl    _savefpr_20_l
  93.     .globl    _savefpr_21_l
  94.     .globl    _savefpr_22_l
  95.     .globl    _savefpr_23_l
  96.     .globl    _savefpr_24_l
  97.     .globl    _savefpr_25_l
  98.     .globl    _savefpr_26_l
  99.     .globl    _savefpr_27_l
  100.     .globl    _savefpr_28_l
  101.     .globl    _savefpr_29_l
  102.     .globl    _savefpr_30_l
  103.     .globl    _savefpr_31_l
  104.  
  105.         .long    0x00400000    # traceback tag
  106. _savefpr_14_l:    stfd    14,-144(11)    # save fp registers
  107. _savefpr_15_l:  stfd    15,-136(11)
  108. _savefpr_16_l:  stfd    16,-128(11)
  109. _savefpr_17_l:  stfd    17,-120(11)
  110. _savefpr_18_l:  stfd    18,-112(11)
  111. _savefpr_19_l:  stfd    19,-104(11)
  112. _savefpr_20_l:  stfd    20,-96(11)
  113. _savefpr_21_l:  stfd    21,-88(11)
  114. _savefpr_22_l:  stfd    22,-80(11)
  115. _savefpr_23_l:  stfd    23,-72(11)
  116. _savefpr_24_l:  stfd    24,-64(11)
  117. _savefpr_25_l:  stfd    25,-56(11)
  118. _savefpr_26_l:  stfd    26,-48(11)
  119. _savefpr_27_l:  stfd    27,-40(11)
  120. _savefpr_28_l:  stfd    28,-32(11)
  121. _savefpr_29_l:  stfd    29,-24(11)
  122. _savefpr_30_l:  stfd    30,-16(11)
  123. _savefpr_31_l:  stfd    31,-8(11)
  124.         stw    0,4(11)        # save return address also
  125.         blr
  126.  
  127.  
  128. # Routines for restoring floating point registers, called by the compiler.
  129. # Called with r11 pointing to the stack header word of the caller of the
  130. # function, just beyond the end of the floating point save area.
  131.  
  132.     .globl    _restfpr_14_l
  133.     .globl    _restfpr_15_l
  134.     .globl    _restfpr_16_l
  135.     .globl    _restfpr_17_l
  136.     .globl    _restfpr_18_l
  137.     .globl    _restfpr_19_l
  138.     .globl    _restfpr_20_l
  139.     .globl    _restfpr_21_l
  140.     .globl    _restfpr_22_l
  141.     .globl    _restfpr_23_l
  142.     .globl    _restfpr_24_l
  143.     .globl    _restfpr_25_l
  144.     .globl    _restfpr_26_l
  145.     .globl    _restfpr_27_l
  146.     .globl    _restfpr_28_l
  147.     .globl    _restfpr_29_l
  148.     .globl    _restfpr_30_l
  149.     .globl    _restfpr_31_l
  150.  
  151.         .long    0x00600000    # traceback tag
  152. _restfpr_14_l:    lfd    14,-144(11)    # restore fp registers
  153. _restfpr_15_l:  lfd    15,-136(11)
  154. _restfpr_16_l:  lfd    16,-128(11)
  155. _restfpr_17_l:  lfd    17,-120(11)
  156. _restfpr_18_l:  lfd    18,-112(11)
  157. _restfpr_19_l:  lfd    19,-104(11)
  158. _restfpr_20_l:  lfd    20,-96(11)
  159. _restfpr_21_l:  lfd    21,-88(11)
  160. _restfpr_22_l:  lfd    22,-80(11)
  161. _restfpr_23_l:  lfd    23,-72(11)
  162. _restfpr_24_l:  lfd    24,-64(11)
  163. _restfpr_25_l:  lfd    25,-56(11)
  164. _restfpr_26_l:  lfd    26,-48(11)
  165. _restfpr_27_l:  lfd    27,-40(11)
  166. _restfpr_28_l:  lfd    28,-32(11)
  167. _restfpr_29_l:  lfd    29,-24(11)
  168. _restfpr_30_l:  lfd    30,-16(11)
  169. _restfpr_31_l:  lwz    0,4(11)        # caller's caller address
  170.         lfd    31,-8(11)
  171.         mtlr    0
  172.         mr    1,11
  173.         blr
  174.